package com.ymatou.query.trading.api.testcase;

import java.util.ArrayList;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.query.trading.api.parameter.GetSellerOrderCountBean;
import com.ymatou.query.trading.api.service.GetSellerOrderCountCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.YMTDateUtil;
import com.ymttest.utils.constant.ECode;

/**
 * 获取商家订单数量 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_GetSellerOrderCount {

	private static GetSellerOrderCountBean getsellerordercountbean;
	private static GetSellerOrderCountCall getsellerordercountcall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取商家订单数量");
	}

	@Before
	public void caseUp() {

		getsellerordercountbean = new GetSellerOrderCountBean();
		getsellerordercountcall = new GetSellerOrderCountCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getsellerordercountcall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetSellerOrderCount_001() {
		Logger.start(true,"获取商家非闪购订单数量成功");
		try {
			// 准备参数
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			// 开始时间
			String BeginTime = YMTDateUtil.getBeforeOrNextDay(-40);
			getsellerordercountbean.setBeginTime(BeginTime);
			// 结束时间
			String EndTime = YMTDateUtil.getBeforeOrNextDay(1);
			getsellerordercountbean.setEndTime(EndTime);
			// 是否为闪购订单
			getsellerordercountbean.setIsShangouOrder(false);
			ArrayList<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(4);
			getsellerordercountbean.setOrderStatusList(OrderStatusList);
			getsellerordercountbean.setSellerId(SellerId);
			// 发送请求
			getsellerordercountcall.setData(getsellerordercountbean);
			getsellerordercountcall.callService();
			Logger.comment("getsellerordercountcall send:" + getsellerordercountcall.getEntityString());
			Logger.comment("getsellerordercountcall response:" + getsellerordercountcall.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, getsellerordercountcall.getCode(), "验证Code");
			// Logger.verifyEquals(ErrorCode.SUCCESSMSG,
			// getsellerordercountcall.getMsg(), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetSellerOrderCount_002() {
		Logger.start(true,"获取商家闪购订单数量成功");
		try {
			// 准备参数
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			// 开始时间
			String BeginTime = YMTDateUtil.getBeforeOrNextDay(-40);
			getsellerordercountbean.setBeginTime(BeginTime);
			// 结束时间
			String EndTime = YMTDateUtil.getBeforeOrNextDay(1);
			getsellerordercountbean.setEndTime(EndTime);
			// 是否为闪购订单
			getsellerordercountbean.setIsShangouOrder(true);
			ArrayList<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(4);
			getsellerordercountbean.setOrderStatusList(OrderStatusList);
			getsellerordercountbean.setSellerId(SellerId);
			// 发送请求
			getsellerordercountcall.setData(getsellerordercountbean);
			getsellerordercountcall.callService();
			int num1 = getsellerordercountcall.getReceivedNum();
			// 是否为闪购订单
			getsellerordercountbean.setIsShangouOrder(false);
			getsellerordercountcall.setData(getsellerordercountbean);
			getsellerordercountcall.callService();
			int num2 = getsellerordercountcall.getReceivedNum();
			Logger.comment("getsellerordercountcall2 send:" + getsellerordercountcall.getEntityString());
			Logger.comment("getsellerordercountcall2 response:" + getsellerordercountcall.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, getsellerordercountcall.getCode(), "验证Code");
			Logger.verifyEquals(false, num1 == num2, "验证查询闪购订单和非闪购订单结果是否相同");
			// Logger.verifyEquals(ErrorCode.SUCCESSMSG,
			// getsellerordercountcall.getMsg(), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetSellerOrderCount_003() {
		Logger.start(true,"获取商家闪购订单数量成功");
		try {
			// 准备参数
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			// 开始时间
			String BeginTime = YMTDateUtil.getBeforeOrNextDay(-40);
			getsellerordercountbean.setBeginTime(BeginTime);
			// 结束时间
			String EndTime = YMTDateUtil.getBeforeOrNextDay(1);
			getsellerordercountbean.setEndTime(EndTime);
			// 是否为闪购订单
			ArrayList<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(4);
			getsellerordercountbean.setOrderStatusList(OrderStatusList);
			getsellerordercountbean.setSellerId(SellerId);
			getsellerordercountbean.setIsShangouOrder(true);
			// 发送请求
			getsellerordercountcall.setData(getsellerordercountbean);
			getsellerordercountcall.callService();
			Logger.comment("getsellerordercountcall send:" + getsellerordercountcall.getEntityString());
			Logger.comment("getsellerordercountcall response:" + getsellerordercountcall.getReturnData());
			int num1 = getsellerordercountcall.getReceivedNum();
			// 是否为闪购订单
			getsellerordercountbean.setIsShangouOrder(false);
			Logger.debug("getsellerordercountbean:" + getsellerordercountbean.getIsShangouOrder());
			// getsellerordercountcall.setData(getsellerordercountbean);
			getsellerordercountcall.callService();
			int num2 = getsellerordercountcall.getReceivedNum();
			Logger.comment("getsellerordercountcall send:" + getsellerordercountcall.getEntityString());
			Logger.comment("getsellerordercountcall response:" + getsellerordercountcall.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, getsellerordercountcall.getCode(), "验证Code");
			Logger.verifyEquals(false, num1 == num2, "验证查询闪购订单和非闪购订单结果是否相同");
			// Logger.verifyEquals(ErrorCode.SUCCESSMSG,
			// getsellerordercountcall.getMsg(), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}